'''
$Revision: 17 $
$LastChangedDate: 2007-05-11 16:00:08 +0000 (Fri, 11 May 2007) $
Some basic unittesting
Really need to expand this.
'''
import unittest
import pysces
import os, sys
from sandbox.PyscesCore2 import NewCore

class TestNewCore(unittest.TestCase):
    '''Tests the NewCore'''
    
    def setUp(self):
        
        pysces.PyscesModel.model_dir = os.getcwd() + '/test/models/'

    def __testLists(self, list1, list2):
        if len(list1) != len(list2):
            return False

        for value in list1:
            if value not in list2:
                return False
        return True


    def testTestBranch1(self):
        '''
        Tests NewCore against the model pysces_test_branch1
        '''

        self.m = pysces.model('pysces_test_branch1.psc')
        self.m.doLoad()
        modmap = NewCore(self.m)
        
        self.assertEqual(True, self.__testLists(modmap.hasReactions(), ['R0', 'R1', 'R2', 'R3', 'R4', 'R5']))
        self.assertEqual(True, self.__testLists(modmap.hasSpecies(), ['s1', 's2', 's3', 's4', 'x6', 'x5', 'x0']))
        self.assertEqual(True, self.__testLists(modmap.hasFixedSpecies(), ['x6', 'x5', 'x0']))

        self.assertEqual(True,self.__testLists(modmap.R1.hasReagents(),['s1', 's2']))
        self.assertEqual(True,self.__testLists(modmap.R1.hasSubstrates(),['s1']))
        self.assertEqual(True,self.__testLists(modmap.R1.hasProducts(),['s2']))
        self.assertEqual(True,self.__testLists(modmap.R1.hasModifiers(),[]))

        self.assertEqual(True,self.__testLists(modmap.s1.isReagentOf(),['R0','R1']))
        self.assertEqual(True,self.__testLists(modmap.s1.isSubstrateOf(),['R1']))
        self.assertEqual(True,self.__testLists(modmap.s1.isProductOf(),['R0']))
        self.assertEqual(True,self.__testLists(modmap.s1.isModifierOf(),[]))



if __name__ == '__main__':
    unittest.main()
